#include <algorithm>
#include <common.h>
#include <ios>
#include <iostream>
#include <ranges>
#include <reduce_ops.h>
#include <transpose_ops.h>
#include <vector>
using namespace std;
int main() {
    // const unsigned int N = 1 << 24;
    // int *h_in = new int[N];
    // fill(h_in, h_in + N, 1);
    // int sum_cpu = reduce_sum_cpu(h_in, N);
    // // float sum_gpu = reduce_sum_cuda(h_in,N,NEIGHBORED);
    // int sum_gpu1 = reduce_sum_cuda(h_in, N);
    // // int sum_gpu = reduce_sum_cuda(h_in,N,WARP_UNROLL8);
    // int sum_gpu = reduce_sum_cuda(h_in, N, WARP_SMEM_UNROLL8);
    // if (abs(sum_cpu - sum_gpu) < 1e-4) {
    //     cout << "计算正确\n";
    // } else {
    //     cout << "CPU = " << sum_cpu << " GPU = " << sum_gpu << " 计算错误\n";
    // }
    unsigned int N = 1 << 20;
    int *h_in = new int[N];
    int *h_out = new int[N];
    int *h_cuda = new int[N];
    // random_uniform(h_in, 1, 10, N, 123);
    generate(h_in, 0, N);
    transpose_cpu(h_out, h_in, 1024, 1024);
    transpose_cuda(h_cuda, h_in, 1024, 1024);
    std::cout << std::boolalpha << is_same_array(h_out, h_cuda, N);
    delete[] h_in;
    delete[] h_out;
    delete[] h_cuda;
    // for (int i = 0; i < N; i++) {
    //     std::cout << h_in[i] << "\n";
    // }
    // for (int i : views::iota(0, 10)) {
    //     std::cout << i << " ";
    // }
    // for (int i = 0; i < N; i++) {
    //     std::cout << h_in[i] << "\n";
    // }
}
